package com.eva.service.cms;

import com.eva.enums.CmsArticleStatusEnum;
import com.eva.dao.cms.CmsArticleMapper;
import com.eva.dao.cms.model.CmsArticle;
import com.eva.framework.mp.service.BaseService;
import com.eva.service.cms.vo.CmsArticleDetailVO;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;

@Service
public class CmsArticleService extends BaseService<CmsArticle, CmsArticleMapper> {

    public CmsArticleService(CmsArticleMapper mapper, Environment environment) {
        super(mapper, environment);
    }

    /**
     * 查询详情
     *
     * @param uid 文章唯一标识
     * @param mode 模式（preview：预览模式）
     * @return CmsArticleDetailVO
     */
    public CmsArticleDetailVO findDetail(String uid, String mode) {
        String status = CmsArticleStatusEnum.ONLINE.name();
        if ("preview".equals(mode)) {
            status = null;
        }
        return mapper.selectDetail(uid, status);
    }
}
